import './index.scss';
import React from 'react';

//定义按钮仅有的4种颜色
const btnTypes = ['primary', 'success', 'warn', 'danger'];

function MyButton(props) {
  const { type, children, ...restProps } = props;
  // console.log(type);
  //success
  // console.log(children);
  //Click

  const createStyleClass = () => {
    let _type = btnTypes.includes(type);
    _type = _type ? `btn-${type}` : 'btn-primary';

    let className = ['btn', _type].join(' ');
    // console.log(className);
    //btn btn-success

    return className;
  };

  return (
    <button {...restProps} className={createStyleClass()}>
      {children}
    </button>
  );
}

export default MyButton;
